export default {
	set(key, data, callback, failCall) {
		uni.setStorage({
			key: key,
			data: data,
			success: () => {
				if (typeof callback === 'function') {
					this.getToken((res) => {
						callback(res)
					})
				}
			},
			fail(error) {
				if (typeof failCall === 'function') {
					failCall(error)
				}
			}
		});
	},
	// 获取 token
	get(key, successCallback, failCallback) {
		if (typeof successCallback === 'function') {
			uni.getStorage({
				key: key,
				success: function(res) {
					if (typeof successCallback === 'function') {
						successCallback(res.data)
					}
				},
				fail: function(error) {
					if (typeof failCallback === 'function') {
						failCallback(error)
					}
				}
			});
		} else {
			try {
				return uni.getStorageSync(key)
			} catch (e) {
				// error
			}
		}
	}
}
